Reading layer `MP14_PLNG_AREA_WEB_PL' from data source
`/Users/geloliu/Gelo-608/ISSS608/ISSS608-VAA-GroupProject/ShinyApp/data/geospatial'
using driver `ESRI Shapefile'
Simple feature collection with 55 features and 12 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 2667.538 ymin: 15748.72 xmax: 56396.44 ymax: 50256.33
Projected CRS: SVY21
age <-read_csv("data/ResidentPopulationbyPlanningAreaSubzoneofResidenceAgeGroupandFloorAreaofResidenceCensusofPopulation2020.csv")
Rows: 388 Columns: 121
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (121): Number, Total1_Total, Total1_0_4, Total1_5_9, Total1_10_14, Total...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
income <-read_excel("data/ResidentHouseholdsbyPlanningAreaofResidenceandMonthlyHouseholdIncomefromWorkCensusOfPopulation2020.xlsx",sheet ="sheet1",range="A11:U43")
age <-left_join(mpsz,age,by =c("PLN_AREA_N"="PA"))
income <- income %>%mutate(across(2:21, as.numeric))income_proportion <- income %>%mutate(across(3:21, ~round(. / income[[2]] *100, 2))) %>%mutate(`LowerIncome%`=rowSums(select(.,3:6), na.rm =TRUE))low_income <- income_proportion %>%select(c(`Planning Area of Residence`,`LowerIncome%`))%>%mutate(`Planning Area of Residence`=toupper(`Planning Area of Residence`))
low_income <-left_join(mpsz,low_income,by =c("PLN_AREA_N"="Planning Area of Residence"))
# Ensure both layers have the same CRSlow_income <-st_transform(low_income, st_crs(age))# Set the tmap mode to view (interactive)tmap_mode("view")
ℹ tmap mode set to "view".
# Create the map with multiple layerstm_shape(age) +tm_fill(col ="Aged%", palette ="Blues", title ="Aged Population(%)",alpha =0.9,style ="quantile") +tm_borders(col ="white", lwd =0.5, alpha =0.5) +tm_shape(low_income) +tm_fill(col ="LowerIncome%", palette ="YlOrRd", title ="IncomeBelow:3000(%)", style ="quantile",n =5,alpha =0.6) +tm_borders(col ="darkgrey", lwd =0.5, alpha =0.5) +tm_basemap(server ="CartoDB.Positron") +tm_layout(title ="Aged and Low-Income Population Across Singapore", legend.outside =TRUE,legend.outside.position ="right")
── tmap v3 code detected ───────────────────────────────────────────────────────
[v3->v4] `tm_polygons()`: instead of `style = "quantile"`, use fill.scale =
`tm_scale_intervals()`.
ℹ Migrate the argument(s) 'style', 'palette' (rename to 'values') to
'tm_scale_intervals(<HERE>)'[v3->v4] `tm_polygons()`: use 'fill' for the fill color of polygons/symbols
(instead of 'col'), and 'col' for the outlines (instead of 'border.col').[v3->v4] `tm_polygons()`: use `fill_alpha` instead of `alpha`.[v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'[v3->v4] `tm_borders()`: use `fill_alpha` instead of `alpha`.[v3->v4] `tm_polygons()`: use `fill_alpha` instead of `alpha`.[v3->v4] `tm_polygons()`: migrate the argument(s) related to the legend of the
visual variable `fill` namely 'title' to 'fill.legend = tm_legend(<HERE>)'[v3->v4] `tm_borders()`: use `fill_alpha` instead of `alpha`.[v3->v4] `tm_layout()`: use `tm_title()` instead of `tm_layout(title = )`[cols4all] color palettes: use palettes from the R package cols4all. Run
`cols4all::c4a_gui()` to explore them. The old palette name "Blues" is named
"brewer.blues"Multiple palettes called "blues" found: "brewer.blues", "matplotlib.blues". The first one, "brewer.blues", is returned.
[cols4all] color palettes: use palettes from the R package cols4all. Run
`cols4all::c4a_gui()` to explore them. The old palette name "YlOrRd" is named
"brewer.yl_or_rd"Multiple palettes called "yl_or_rd" found: "brewer.yl_or_rd", "matplotlib.yl_or_rd". The first one, "brewer.yl_or_rd", is returned.
Rows: 8098 Columns: 16
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (13): station, daily_rainfall_total_mm, highest_30_min_rainfall_mm, high...
dbl (3): year, month, day
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
station <- station %>%select(1:13) %>%mutate(across(5:13, as.numeric), # Convert only numeric columnsdate =make_date(year, month, day),station =as.factor(station) )
Warning: There were 9 warnings in `mutate()`.
The first warning was:
ℹ In argument: `across(5:13, as.numeric)`.
Caused by warning:
! NAs introduced by coercion
ℹ Run `dplyr::last_dplyr_warnings()` to see the 8 remaining warnings.
ggplot(station, aes(x = mean_temperature_c, y = station, fill = station)) +geom_density_ridges(scale =2, rel_min_height =0.01, alpha =0.5 ) +labs(title ="Distribution of Temperature Across Stations",x ="Mean Temperature (°C)", y ="Station") +theme(panel.background =element_rect(fill ="#f3f1e9"),plot.background =element_rect(fill ="#f3f1e9", color =NA),legend.position ="none",plot.title =element_text(face ="bold") )
Picking joint bandwidth of 0.215
Warning: Removed 3850 rows containing non-finite outside the scale range
(`stat_density_ridges()`).
ggplot(station, aes(x = station,y = mean_temperature_c)) +stat_halfeye(alpha =0.5,adjust =0.5,justification =-0.1,.width =0,fill ="#8AA4FF")+geom_boxplot(width =0.10,outlier.shape =NA,color="grey50")+labs(title ="Distribution of Mean Temperature Across Stations",x ="", y="Mean Temperature")+coord_flip() +theme(panel.background =element_rect(fill ="#ffffff"),plot.background =element_rect(fill ="#ffffff",color =NA),legend.position ='none',plot.title =element_text(face ="bold",size=13,hjust=0.5))
Warning: Removed 3850 rows containing missing values or values outside the scale range
(`stat_slabinterval()`).
Warning: Removed 3850 rows containing non-finite outside the scale range
(`stat_boxplot()`).